local table_name = "stage"
local old_table = IMPORT_D:get_table(table_name)
if not old_table then
    return
end

local new_table = {}
for _, tbl in pairs(old_table) do repeat
    if tbl.id == 0 then
        break
    end

    local stage = {}
    for round = 0, 9 do
        local monsters = tbl["monster"..round]
        if not monsters then
            break
        end

        local monster_map = {}
        for _, monster_id in ipairs(string.split(monsters, ";")) do
            monster_id = tonumber(monster_id)
            monster_map[monster_id] = (monster_map[monster_id] or 0) + 1
        end

        ---! round + 1 保证 stage 列表的 index 是从 1 开始计数，而不是从 0 开始
        ---! 这样能保证 stage 只是一个纯数组，数组的特性不至于被哈希表污染而丧失
        stage[round + 1] = monster_map
    end
    new_table[tbl.lv] = stage
until true end

IMPORT_D:set(table_name, new_table)
